package parser;

import antlr.RecognitionException;
import antlr.Token;
import java.util.*;

class ListFor extends Expr {
    
    Expr temp;
    Stmt body;
    
    ListFor(Stmt body, Expr temp) throws RecognitionException {
        this.body = body;
        this.temp = temp;
        temp.lhs();
        if (body.yields)
            throw new RecognitionException("Cannot yield in a list comprehension");
    }
    
    void write(ByteStream out) throws RecognitionException {
        out.write(Opcodes.LIST);
        out.write(0);
        temp.writeLHS(out);
        body.write(out);
        temp.write(out);
    }
    
    void writeLHS(ByteStream out) throws RecognitionException {
        throw new RecognitionException("Cannot assign to list comprehension");
    }
        
    void delete(ByteStream out) throws RecognitionException {
        throw new RecognitionException("Cannot delete rvalue");
    }
       
}
